<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:a="http://richfaces.org/a4j"
	xmlns:rg="http://www.ruijie.com.cn/faces/ui" template="/layout/contentLayout.xhtml">

	<ui:param name="param_navigationUrl" value="/luyuan/promotion/navigationPromotion.jsf" />

	<ui:define name="road">
		<span><h:outputLink value="listPromotion.jsf">促销活动</h:outputLink> </span>
	</ui:define>

	<ui:define name="content">
		<rg:areaPanel>
			<h:form id="promotionForm">
				<rg:titlePanel headerTitle="修改促销活动" needButton="true">
					<rg:fieldSet column="double">
						<rg:inputText id="name" label="活动主题" singleLine="true" textStyle="width: 320px"
							value="#{promotionAction.model.theme}" required="true" />
						<rg:calendar id="startDate" label="开始时间" value="#{promotionAction.model.startDate}" required="true" />
						<rg:calendar id="endDate" label="结束时间" value="#{promotionAction.model.endDate}" required="true" />
						<rg:inputArea id="content" label="活动内容" singleLine="true" textStyle="width: 320px"
							value="#{promotionAction.model.content}" />
						<rg:inputText id="target" label="活动对象" singleLine="true" textStyle="width: 320px"
							value="#{promotionAction.model.target}" />
						<rg:selectOne id="model" label="促销方式" singleLine="true" textStyle="width: 320px" disabled="true"
							value="#{promotionAction.promotionModel.model}">
							<f:selectItem itemLabel="特殊活动价" itemValue="cash" />
							<f:selectItem itemLabel="积分金额兑换" itemValue="integral" />
							<f:selectItem itemLabel="积分+现金兑换" itemValue="cash_integral" />
							<f:selectItem itemLabel="买N送N" itemValue="n4m" />
							<f:selectItem itemLabel="买满立减" itemValue="reduction" />
							<a:support event="onchange" reRender="#{id}_messagePanel"
								actionListener="#{promotionAction.onPromotionModelChange}" ajaxSingle="true" />
						</rg:selectOne>
						<rg:inputText id="discount" label="现金折扣" tip="例如：7折，写0.7。" value="#{promotionAction.promotionModel.discount}">
							<rg:relevant for="model" relevantValue="^(cash|cash_integral)$" type="show" />
						</rg:inputText>
						<rg:inputText id="integralTimes" label="兑换积分倍率" value="#{promotionAction.promotionModel.integralTimes}">
							<rg:relevant for="model" relevantValue="^(integral|cash_integral)$" type="show" />
						</rg:inputText>
						<rg:inputText id="n" label="买满数量" textStyle="width: 320px" value="#{promotionAction.promotionModel.n}">
							<rg:relevant for="model" relevantValue="^(n4m)$" type="show" />
						</rg:inputText>
						<rg:inputText id="m" label="赠送数量" textStyle="width: 320px" value="#{promotionAction.promotionModel.m}">
							<rg:relevant for="model" relevantValue="^(n4m)$" type="show" />
						</rg:inputText>
						<rg:inputText id="l" label="买满金额" textStyle="width: 320px" value="#{promotionAction.promotionModel.l}">
							<rg:relevant for="model" relevantValue="^(reduction)$" type="show" />
						</rg:inputText>
						<rg:inputText id="d" label="减免金额" textStyle="width: 320px" value="#{promotionAction.promotionModel.d}">
							<rg:relevant for="model" relevantValue="^(reduction)$" type="show" />
						</rg:inputText>
						<rg:selectOne id="limited" label="促销限制" singleLine="true" textStyle="width: 320px" disabled="true"
							value="#{promotionAction.promotionLimited.limited}">
							<f:selectItem itemLabel="买满金额" itemValue="amount" />
							<f:selectItem itemLabel="买几件以上" itemValue="package" />
							<f:selectItem itemLabel="会员级别" itemValue="memberLevel" />
							<a:support event="onchange" reRender="#{id}_messagePanel"
								actionListener="#{promotionAction.onPromotionLimitedChange}" ajaxSingle="true" />
						</rg:selectOne>
						<rg:inputText id="amount" label="买满金额" singleLine="true" textStyle="width: 320px"
							value="#{promotionAction.promotionLimited.amount}">
							<rg:relevant for="limited" relevantValue="^(amount)$" type="show" />
						</rg:inputText>
						<rg:inputText id="packingNumber" label="买几件以上" singleLine="true"
							value="#{promotionAction.promotionLimited.packingNumber}" textStyle="width: 320px">
							<rg:relevant for="limited" relevantValue="^(package)$" type="show" />
						</rg:inputText>
						<rg:selectOne id="memberLevel" label="会员级别" singleLine="true" textStyle="width: 320px"
							value="#{promotionAction.promotionLimited.memberLevel}" itemsProvider="#{memberLevelProvider}"
							converter="#{memberLevelConverter}">
							<rg:relevant for="limited" relevantValue="^(memberLevel)$" type="show" />
						</rg:selectOne>
						<rg:pickList id="products" label="促销产品" singleLine="true" value="#{promotionAction.products}"
							itemsProvider="#{promotionProductProvider.getSelectItems(null)}" converter="#{productConverter}" />
					</rg:fieldSet>
					<ui:define name="panelButton">
						<h:commandButton styleClass="button" value="#{messages.btn_complete}" action="/luyuan/promotion/listPromotion.jsf"
							actionListener="#{promotionAction.updatePromotion}" />

						<h:commandButton styleClass="button" value="取消" action="/luyuan/promotion/listPromotion.jsf" immediate="true" />
					</ui:define>
				</rg:titlePanel>
			</h:form>
		</rg:areaPanel>
	</ui:define>
</ui:composition>
